<?php
class Form_Ajoutervip extends Zend_Form
{
	public function init(){
		$this->setMethod('post');
		$this->setName('Ajouter VIP\'s');

		$vipnom = new Zend_Form_Element_Text('nomVip');
		$vipnom	->setLabel('Nom *')
				->addFilter('StripTags')
				->addValidator('StringLength', false,array(3 ,20))
				->addValidator('alnum')
				->addValidator('regex', false, array('/^[A-z]+/'))
				->addFilter('StringTrim')
				->setRequired(true);
		$this->addElement($vipnom);
			
		$vipprenom = new Zend_Form_Element_Text('prenomVip');
		$vipprenom	->setLabel('Prenom *')
				->addFilter('StripTags')
				->addValidator('StringLength', false,array(3 ,20))
				->addValidator('alnum')
				->addValidator('regex', false, array('/^[A-z]+/'))
				->addFilter('StringTrim')
				->setRequired(true);
		$this->addElement($vipprenom);

		$vipsex = new Zend_Form_Element_Select('sexVip');
		$vipsex		->addMultiOptions(array(
				'M' => 'Homme',
				'F' => 'Femme'
			));
		
		$vipsex	->setLabel('Sexe');
		$this->addElement($vipsex);
		
		$vipdate = new Zend_Form_Element_Text('dateVip');
		$vipdate	->setLabel('Date de naissance')
					->setAttrib('placeholder','jj/mm/aaaa')
					->addFilter('StripTags')	
					->addValidator('StringLength', false,array(10 ,10))
					->addFilter('StringTrim');
		$this->addElement($vipdate);
		
		$natVip = new Zend_Form_Element_Select('natVip');
		$natVip		->setLabel('Nationalité')
					->setRequired(true)
					->addMultiOptions(array('0' => 'Selectionner la nationalité'));
		$this->addElement($natVip);
		
		$vipcom = new Zend_Form_Element_Textarea('comVip');
		$vipcom	->setLabel('Commentaire')
				->setAttrib('cols','40')
				->setAttrib('rows','4');
		$this->addElement($vipcom);
	
		$vipprof = new Zend_Form_Element_MultiCheckbox('profVip', array(
		    'multiOptions' => array(
		        'acteur' => 'Acteur',
		        'realisateur' => 'Réalisateur',
		        'chanteur' => 'Chanteur',
		        'mannequin' => 'Mannequin',
		        'couturier' => 'Couturier'
		    )
		));
		$vipprof->setLabel('Profession(s) *')
				->setRequired(true);
		$this->addElement($vipprof);
	
		$vipimg = new Zend_Form_Element_File('imgVip');
		$vipimg	->setLabel('Selectionner une photo')
		        ->setDestination('../public/images/');
		$vipimg->addValidator('Count', false, 1);
		$vipimg->addValidator('Size', false, 5120000);
		$vipimg->addValidator('Extension', false, 'jpg,png,gif');
		$this->addElement($vipimg, 'imgVip');
		
		$this->setAttrib('enctype', 'multipart/form-data');

		$vipimgsujet = new Zend_Form_Element_Text('imgsujetVip');
		$vipimgsujet
				->setLabel('Sujet')
				->addFilter('StripTags')
				->addValidator('StringLength', false,array(0 ,220))
				->addFilter('StringTrim');
		$this->addElement($vipimgsujet);

		$vipimgcom = new Zend_Form_Element_Text('imgcomVip');
		$vipimgcom	->setLabel('Commentaire')
				->addFilter('StripTags')
				->addValidator('StringLength', false,array(0 ,250))
				->addFilter('StringTrim');
		$this->addElement($vipimgcom);
		
		$vipmari = new Zend_Form_Element_Select('vipmariVip');
		$vipmari ->setLabel("Mariage actuel")
				 ->addMultiOptions(array('0' =>'Selectionner le Vip'))
				 ->setValue('0');				
		$this->addElement($vipmari);
		
		$vipdatemari = new Zend_Form_Element_Text('datemariVip');
		$vipdatemari
					->setLabel('Date')
					->setAttrib('placeholder','jj/mm/aaaa')
					->addFilter('StripTags')	
					->addValidator('StringLength', false,array(10 ,10))
					->addFilter('StringTrim');
		$this->addElement($vipdatemari);
			
		$vipdatefinmari = new Zend_Form_Element_Text('datefinmariVip');
		$vipdatefinmari
					->setLabel('Date de fin du mariage')
					->setAttrib('placeholder','jj/mm/aaaa')
					->addFilter('StripTags')	
					->addValidator('StringLength', false,array(10 ,10))
					->addFilter('StringTrim');
		$this->addElement($vipdatefinmari);
		
		$vipliai = new Zend_Form_Element_Select('vipliaiVip');
		$vipliai ->setLabel("Liaison actuel")
				 ->addMultiOptions(array('0' =>'Selectionner le Vip'))
				 ->setValue('0');
		$this->addElement($vipliai);
				
		$vipdateliai = new Zend_Form_Element_Text('dateliaiVip');
		$vipdateliai->setLabel('Date')
					->setAttrib('placeholder','jj/mm/aaaa')
					->addFilter('StripTags')	
					->addValidator('StringLength', false,array(10 ,10))
					->addFilter('StringTrim');
		$this->addElement($vipdateliai);
					
		$vipliaimotif = new Zend_Form_Element_Text('liaimotifVip');
		$vipliaimotif
				->setLabel('Motif')
				->addFilter('StripTags')
				->addValidator('StringLength', false,array(0 ,220))
				->addFilter('StringTrim');
		$this->addElement($vipliaimotif);
				
		$submitButton = new Zend_Form_Element_Submit('Valider');
		$this->addElement($submitButton); 
		
		$resetButton = new Zend_Form_Element_Reset('Annuler');
		$this->addElement($resetButton);
	}

	public function remplirNation($resu){
		foreach ($resu as $ligne){
			$this -> natVip -> addMultiOption($ligne->NATIONALITE_NUMERO, $ligne->NATIONALITE_NOM);
		}
	}
	
	public function remplirVip($resu){
		foreach ($resu as $ligne){
			$this -> vipmariVip -> addMultiOption($ligne->VIP_NUMERO, $ligne->VIP_NOM." ".$ligne->VIP_PRENOM);
			$this -> vipliaiVip -> addMultiOption($ligne->VIP_NUMERO, $ligne->VIP_NOM." ".$ligne->VIP_PRENOM);
		}
	}
}
?>